home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Text / WASTE / WASTE 1.2a2 / WASTE.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-12  |  31.5 KB  |  740 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.2a2 (September 1995)
  7.  *
  8.  *    Copyright (c) 1993-1995 Marco Piovanelli
  9.  *    All Rights Reserved
  10.  * 
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef __CONDITIONALMACROS__
  17. #include <ConditionalMacros.h>
  18. #endif
  19.  
  20. #ifndef __TYPES__
  21. #include <Types.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __QUICKDRAWTEXT__
  29. #include <QuickdrawText.h>
  30. #endif
  31.  
  32. #ifndef __QUICKDRAW__
  33. #include <Quickdraw.h>
  34. #endif
  35.  
  36. #ifndef __SCRIPT__
  37. #include <Script.h>
  38. #endif
  39.  
  40. #ifndef __TEXTUTILS__
  41. #include <TextUtils.h>
  42. #endif
  43.  
  44. #ifndef __TEXTEDIT__
  45. #include <TextEdit.h>
  46. #endif
  47.  
  48. #ifndef __DRAG__
  49. #include <Drag.h>
  50. #endif
  51.  
  52. #ifndef __LONGCOORDINATES__
  53. #ifndef _LongCoords_
  54. #include "LongCoords.h"
  55. #endif
  56. #endif
  57.  
  58. // if we're using a pre-2.1 version of the Universal Headers, define EventModifiers
  59. #ifndef UNIVERSAL_INTERFACES_VERSION
  60. typedef unsigned short EventModifiers;
  61. #endif
  62.  
  63. #if defined(powerc) || defined (__powerc)
  64. #pragma options align=mac68k
  65. #endif
  66.  
  67. #define WASTE11
  68.  
  69. /*    result codes */
  70.  
  71. enum {
  72.     weCantUndoErr            =    -10015,    /* undo buffer is clear (= errAECantUndo) */
  73.     weEmptySelectionErr        =    -10013,    /* selection range is empty (= errAENoUserSelection) */
  74.     weNotHandledErr            =    -1708,    /* please use default behavior (= errAEEventNotHandled) */
  75.     weUnknownObjectTypeErr    =    -9478,    /* specified object type is not registered */
  76.     weObjectNotFoundErr        =    -9477,    /* no object found at specified offset */
  77.     weReadOnlyErr            =    -9476,    /* instance is read-only */
  78.     weUndefinedSelectorErr    =    -50        /* unknown selector (= paramErr) */
  79. };
  80.  
  81. /*    alignment styles */
  82.  
  83. enum {
  84.     weFlushLeft         =    -2,        /* flush left */
  85.     weFlushRight        =    -1,        /* flush right */
  86.     weFlushDefault        =     0,        /* flush according to system direction */
  87.     weCenter            =     1,        /* centered */
  88.     weJustify            =     2        /* fully justified */
  89. };
  90.  
  91. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  92.  
  93. enum {
  94.     weDoFont                =    0x0001,
  95.     weDoFace                =    0x0002,
  96.     weDoSize                =    0x0004,
  97.     weDoColor                =    0x0008,
  98.     weDoAll                    =    weDoFont + weDoFace + weDoSize + weDoColor,
  99.     weDoAddSize                =    0x0010,
  100.     weDoToggleFace            =    0x0020,
  101.     weDoReplaceFace            =    0x0040,
  102.     weDoPreserveScript        =    0x0080,
  103.     weDoExtractSubscript    =    0x0100,
  104.     weDoFaceMask            =    0x0200
  105. };
  106.  
  107. /*    values for the edge parameter in WEGetOffset etc. */
  108.  
  109. enum {
  110.     kLeadingEdge = -1,        /* point is on the leading edge of a glyph */
  111.     kTrailingEdge = 0,        /* point is on the trailing edge of a glyph */
  112.     kObjectEdge = 2            /* point is in the middle of an embedded object */
  113. };
  114.  
  115. /*    values for WEFeatureFlag feature parameter */
  116.  
  117. enum {
  118.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  119.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  120.     weFReadOnly            =    5,        /* disallow modifications */
  121.     weFUndo                =    6,        /* support WEUndo() */
  122.     weFIntCutAndPaste    =    7,        /* use intelligent cut-and-paste rules */
  123.     weFDragAndDrop        =    8,        /* support drag-and-drop text editing */
  124.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  125.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  126.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  127. };
  128.  
  129. /*    values for WENew flags parameter */
  130.  
  131. enum {
  132.     weDoAutoScroll        =    1 << weFAutoScroll,
  133.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  134.     weDoReadOnly        =    1 << weFReadOnly,
  135.     weDoUndo            =    1 << weFUndo,
  136.     weDoIntCutAndPaste    =    1 << weFIntCutAndPaste,
  137.     weDoDragAndDrop        =    1 << weFDragAndDrop,
  138.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  139.     weDoUseTempMem        =    1 << weFUseTempMem,
  140.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  141. };
  142.  
  143. /*    values for WEFeatureFlag action parameter */
  144.  
  145. enum {
  146.     weBitToggle = -2,    /* toggles the specified feature */
  147.     weBitTest,            /* returns the current setting of the specified feature */
  148.     weBitClear,            /* disables the specified feature */
  149.     weBitSet            /* enables the specified feature */
  150. };
  151.  
  152. /*    selectors for WEGetInfo and WESetInfo */
  153.  
  154. enum {
  155.     weCharToPixelHook    =    'c2p ',    /* CharToPixel hook */
  156.     weClickLoop            =    'clik',    /* click loop callback */
  157.     weCurrentDrag        =    'drag',    /* drag currently being tracked from WEClick() */
  158.     weDrawTextHook        =    'draw', /* text drawing hook */
  159.     weLineBreakHook        =    'lbrk',    /* line breaking hook */
  160.     wePixelToCharHook    =    'p2c ', /* PixelToChar hook */
  161.     wePort                =    'port',    /* graphics port */
  162.     weRefCon            =    'refc',    /* reference constant for use by application */
  163.     weScrollProc        =    'scrl',    /* auto-scroll callback */
  164.     weText                =    'text',    /* text handle */
  165.     weTranslateDragHook =    'xdrg', /* drag translation callback */
  166.     weTSMDocumentID        =    'tsmd',    /* Text Services Manager document ID */
  167.     weTSMPreUpdate        =    'pre ',    /* Text Services Manager pre-update callback */
  168.     weTSMPostUpdate        =    'post'    /* Text Services Manager post-update callback */
  169. };
  170.  
  171. /*    values for WEInstallObjectHandler handlerSelector parameter */
  172.  
  173. enum {
  174.     weNewHandler        =    'new ',        /* new handler */
  175.     weDisposeHandler    =    'free',        /* dispose handler */
  176.     weDrawHandler        =    'draw',        /* draw handler */
  177.     weClickHandler        =    'clik',        /* click handler */
  178.     weStreamHandler        =    'strm'        /* stream handler */
  179. };
  180.  
  181. /*    action kinds */
  182.  
  183. enum {
  184.     weAKNone            =    0,        /* null action */
  185.     weAKUnspecified        =    1,        /* action of unspecified nature */
  186.     weAKTyping            =    2,        /* some text has been typed in */
  187.     weAKCut                =    3,        /* the selection range has been cut */
  188.     weAKPaste            =    4,        /* something has been pasted */
  189.     weAKClear            =    5,        /* the selection range has been deleted */
  190.     weAKDrag            =    6,        /* drag and drop operation */
  191.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  192. };
  193.  
  194. /*    destination kinds for stream handler */
  195.  
  196. enum {
  197.     weToScrap            =    0,
  198.     weToDrag            =    1,
  199.     weToSoup            =    2
  200. };
  201.  
  202. typedef struct OpaqueWEReference *WEReference;
  203. typedef struct OpaqueWEObjectReference *WEObjectReference;
  204. typedef Handle WESoupHandle;
  205. typedef short WEActionKind;
  206. typedef FourCharCode WESelector;
  207. typedef WEReference WEHandle;    /* obsolete, kept for backward compatibility */
  208.  
  209. typedef struct WERunInfo {
  210.     long                 runStart;    /* byte offset to first character of style run */
  211.     long                 runEnd;        /* byte offset past last character of style run */
  212.     short                 runHeight;    /* line height (ascent + descent + leading) */
  213.     short                 runAscent;    /* font ascent */
  214.     TextStyle             runStyle;    /* text attributes */
  215.     WEObjectReference    runObject;    /* either NULL or reference to embedded object */
  216. } WERunInfo;
  217.  
  218.  
  219. /*    callback prototypes */
  220.  
  221. typedef pascal Boolean (*WEClickLoopProcPtr)(WEReference we);
  222. typedef pascal void (*WEScrollProcPtr)(WEReference we);
  223. typedef pascal void (*WETSMPreUpdateProcPtr)(WEReference we);
  224. typedef pascal void (*WETSMPostUpdateProcPtr)(WEReference we,
  225.         long fixLength, long inputAreaStart, long inputAreaEnd,
  226.         long pinRangeStart, long pinRangeEnd);
  227. typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference theDrag,
  228.         ItemReference theItem, FlavorType requestedType, Handle putDataHere);
  229. typedef pascal void (*WEDrawTextProcPtr)(Ptr pText, long textLength, Fixed slop,
  230.         JustStyleCode styleRunPosition, WEReference we);
  231. typedef pascal long (*WEPixelToCharProcPtr)(Ptr pText, long textLength, Fixed slop,
  232.         Fixed *pixelWidth, char *edge, JustStyleCode styleRunPosition, Fixed hPos, WEReference we);
  233. typedef pascal short (*WECharToPixelProcPtr)(Ptr pText, long textLength, Fixed slop,
  234.         long offset, short direction, JustStyleCode styleRunPosition, long hPos, WEReference we);
  235. typedef pascal StyledLineBreakCode (*WELineBreakProcPtr)(Ptr pText, long textLength,
  236.         long textStart, long textEnd, Fixed *textWidth, long *textOffset, WEReference we);
  237. typedef pascal void (*WEWordBreakProcPtr)(Ptr pText, short textLength, short offset,
  238.         char edge, OffsetTable breakOffsets, ScriptCode script, WEReference we);
  239. typedef pascal short (*WECharByteProcPtr)(Ptr pText, short textOffset, ScriptCode script,
  240.         WEReference we);
  241. typedef pascal short (*WECharTypeProcPtr)(Ptr pText, short textOffset, ScriptCode script, WEReference we);
  242. typedef pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
  243.         WEObjectReference obj);
  244. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference obj);
  245. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  246.         WEObjectReference obj);
  247. typedef pascal Boolean (*WEClickObjectProcPtr)(Point hitPt, EventModifiers modifiers, unsigned long clickTime,
  248.         WEObjectReference obj);
  249. typedef pascal OSErr (*WEStreamObjectProcPtr)(short destKind, FlavorType *theType,
  250.         Handle putDataHere, WEObjectReference obj);
  251.  
  252.  
  253. /*    UPP proc info */
  254.  
  255. enum {
  256.     uppWEClickLoopProcInfo = kPascalStackBased
  257.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  258.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  259. };
  260. enum {
  261.     uppWEScrollProcInfo = kPascalStackBased
  262.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  263. };
  264. enum {
  265.     uppWETSMPreUpdateProcInfo = kPascalStackBased
  266.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  267. };
  268. enum {
  269.     uppWETSMPostUpdateProcInfo = kPascalStackBased
  270.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  271.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*fixLength*/)))
  272.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*inputAreaStart*/)))
  273.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*inputAreaEnd*/)))
  274.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(long /*pinRangeStart*/)))
  275.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long /*pinRangeEnd*/)))
  276. };
  277. enum {
  278.     uppWETranslateDragProcInfo = kPascalStackBased
  279.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  280.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(DragReference /*theDrag*/)))
  281.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(ItemReference /*theItem*/)))
  282.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(FlavorType /*requestedType*/)))
  283.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  284. };
  285. enum {
  286.     uppWEDrawTextProcInfo = kPascalStackBased
  287.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  288.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  289.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  290.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  291.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(WEReference /*we*/)))
  292. };
  293. enum {
  294.     uppWEPixelToCharProcInfo = kPascalStackBased
  295.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  296.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  297.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  298.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  299.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Fixed * /*pixelWidth*/)))
  300.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(char * /*edge*/)))
  301.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  302.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(Fixed /*hPos*/)))
  303.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  304. };
  305. enum {
  306.     uppWECharToPixelProcInfo = kPascalStackBased
  307.         | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  308.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  309.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  310.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  311.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*offset*/)))
  312.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(short /*direction*/)))
  313.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  314.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(long /*hPos*/)))
  315.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  316. };
  317. enum {
  318.     uppWELineBreakProcInfo = kPascalStackBased
  319.         | RESULT_SIZE(SIZE_CODE(sizeof(StyledLineBreakCode )))
  320.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  321.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  322.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*textStart*/)))
  323.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*textEnd*/)))
  324.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(Fixed * /*textWidth*/)))
  325.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long * /*textOffset*/)))
  326.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  327. };
  328. enum {
  329.     uppWEWordBreakProcInfo = kPascalStackBased
  330.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  331.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textLength*/)))
  332.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(short /*offset*/)))
  333.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(char /*edge*/)))
  334.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(OffsetTable * /*breakOffsets*/)))
  335.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  336.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  337. };
  338. enum {
  339.     uppWECharByteProcInfo = kPascalStackBased
  340.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  341.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  342.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  343.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  344.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  345. };
  346. enum {
  347.     uppWECharTypeProcInfo = kPascalStackBased
  348.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  349.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  350.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  351.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  352.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  353. };
  354.  
  355.  
  356. enum {
  357.     uppWENewObjectProcInfo = kPascalStackBased
  358.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  359.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point * /*defaultObjectSize*/)))
  360.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  361. };
  362. enum {
  363.     uppWEDisposeObjectProcInfo = kPascalStackBased
  364.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  365.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  366. };
  367. enum {
  368.     uppWEDrawObjectProcInfo = kPascalStackBased
  369.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  370.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(const Rect * /*destRect*/)))
  371.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  372. };
  373. enum {
  374.     uppWEClickObjectProcInfo = kPascalStackBased
  375.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  376.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point /*hitPt*/)))
  377.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(EventModifiers /*modifiers*/)))
  378.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(unsigned long /*clickTime*/)))
  379.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  380. };
  381. enum {
  382.     uppWEStreamObjectProcInfo = kPascalStackBased
  383.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  384.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short /*destKind*/)))
  385.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FlavorType * /*theType*/)))
  386.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  387.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  388. };
  389.  
  390.  
  391. /*    UPPs, New≈Proc macros & Call≈Proc macros */
  392.  
  393. /*
  394.     NOTE:
  395.     For compatibility with the Pascal version, Call≈Proc macros take the form:
  396.  
  397.         CallFooProc(..., userRoutine)
  398.  
  399.     instead of:
  400.  
  401.         CallFooProc(userRoutine, ...)
  402.  
  403. */
  404.  
  405. #if GENERATINGCFM
  406.  
  407. typedef UniversalProcPtr WEClickLoopUPP;
  408. typedef UniversalProcPtr WEScrollUPP;
  409. typedef UniversalProcPtr WETSMPreUpdateUPP;
  410. typedef UniversalProcPtr WETSMPostUpdateUPP;
  411. typedef UniversalProcPtr WETranslateDragUPP;
  412. typedef UniversalProcPtr WEDrawTextUPP;
  413. typedef UniversalProcPtr WEPixelToCharUPP;
  414. typedef UniversalProcPtr WECharToPixelUPP;
  415. typedef UniversalProcPtr WELineBreakUPP;
  416. typedef UniversalProcPtr WEWordBreakUPP;
  417. typedef UniversalProcPtr WECharByteUPP;
  418. typedef UniversalProcPtr WECharTypeUPP;
  419. typedef UniversalProcPtr WENewObjectUPP;
  420. typedef UniversalProcPtr WEDisposeObjectUPP;
  421. typedef UniversalProcPtr WEDrawObjectUPP;
  422. typedef UniversalProcPtr WEClickObjectUPP;
  423. typedef UniversalProcPtr WEStreamObjectUPP;
  424.  
  425. #define NewWEClickLoopProc(userRoutine) \
  426.     (WEClickLoopUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickLoopProcInfo, GetCurrentArchitecture())
  427. #define NewWEScrollProc(userRoutine) \
  428.     (WEScrollUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEScrollProcInfo, GetCurrentArchitecture())
  429. #define NewWETSMPreUpdateProc(userRoutine) \
  430.     (WETSMPreUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPreUpdateProcInfo, GetCurrentArchitecture())
  431. #define NewWETSMPostUpdateProc(userRoutine) \
  432.     (WETSMPostUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPostUpdateProcInfo, GetCurrentArchitecture())
  433. #define NewWETranslateDragProc(userRoutine) \
  434.     (WETranslateDragUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETranslateDragProcInfo, GetCurrentArchitecture())
  435. #define NewWEDrawTextProc(userRoutine) \
  436.     (WEDrawTextUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawTextProcInfo, GetCurrentArchitecture())
  437. #define NewWEPixelToCharProc(userRoutine) \
  438.     (WEPixelToCharUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEPixelToCharProcInfo, GetCurrentArchitecture())
  439. #define NewWECharToPixelProc(userRoutine) \
  440.     (WECharToPixelUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharToPixelProcInfo, GetCurrentArchitecture())
  441. #define NewWELineBreakProc(userRoutine) \
  442.     (WELineBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWELineBreakProcInfo, GetCurrentArchitecture())
  443. #define NewWEWordBreakProc(userRoutine) \
  444.     (WEWordBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEWordBreakProcInfo, GetCurrentArchitecture())
  445. #define NewWECharByteProc(userRoutine) \
  446.     (WECharByteUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharByteProcInfo, GetCurrentArchitecture())
  447. #define NewWECharTypeProc(userRoutine) \
  448.     (WECharTypeUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharTypeProcInfo, GetCurrentArchitecture())
  449. #define NewWENewObjectProc(userRoutine) \
  450.     (WENewObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWENewObjectProcInfo, GetCurrentArchitecture())
  451. #define NewWEDisposeObjectProc(userRoutine) \
  452.     (WEDisposeObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDisposeObjectProcInfo, GetCurrentArchitecture())
  453. #define NewWEDrawObjectProc(userRoutine) \
  454.     (WEDrawObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawObjectProcInfo, GetCurrentArchitecture())
  455. #define NewWEClickObjectProc(userRoutine) \
  456.     (WEClickObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickObjectProcInfo, GetCurrentArchitecture())
  457. #define NewWEStreamObjectProc(userRoutine) \
  458.     (WEStreamObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEStreamObjectProcInfo, GetCurrentArchitecture())
  459.  
  460. #define CallWEClickLoopProc(we, userRoutine) \
  461.     CallUniversalProc((userRoutine), uppWEClickLoopProcInfo, (we))
  462. #define CallWEScrollProc(we, userRoutine) \
  463.     CallUniversalProc((userRoutine), uppWEScrollProcInfo, (we))
  464. #define CallWETSMPreUpdateProc(we, userRoutine) \
  465.     CallUniversalProc((userRoutine), uppWETSMPreUpdateProcInfo, (we))
  466. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  467.     CallUniversalProc((userRoutine), uppWETSMPostUpdateProcInfo, (we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  468. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  469.     CallUniversalProc((userRoutine), uppWETranslateDragProcInfo, (theDrag), (theItem), (requestedType), (putDataHere))
  470. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  471.     CallUniversalProc((userRoutine), uppWEDrawTextProcInfo, (pText), (textLength), (slop), (styleRunPosition), (we))
  472. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  473.     CallUniversalProc((userRoutine), uppWEPixelToCharProcInfo, (pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  474. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  475.     CallUniversalProc((userRoutine), uppWECharToPixelProcInfo, (pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  476. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  477.     CallUniversalProc((userRoutine), uppWELineBreakProcInfo, (pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  478. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  479.     CallUniversalProc((userRoutine), uppWEWordBreakProcInfo, (pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  480. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  481.     CallUniversalProc((userRoutine), uppWECharByteProcInfo, (pText), (textOffset), (script), (we))
  482. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  483.     CallUniversalProc((userRoutine), uppWECharTypeProcInfo, (pText), (textOffset), (script), (we))
  484. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  485.     CallUniversalProc((userRoutine), uppWENewObjectProcInfo, (defaultObjectSize), (obj))
  486. #define CallWEDisposeObjectProc(obj, userRoutine) \
  487.     CallUniversalProc((userRoutine), uppWEDisposeObjectProcInfo, (obj))
  488. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  489.     CallUniversalProc((userRoutine), uppWEDrawObjectProcInfo, (destRect), (obj))
  490. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  491.     CallUniversalProc((userRoutine), uppWEClickObjectProcInfo, (hitPt), (modifiers), (clickTime), (obj))
  492. #define CallWEStreamObjectProc(destKind, theType, putDataHere, obj, userRoutine) \
  493.     CallUniversalProc((userRoutine), uppWEStreamObjectProcInfo, (destKind), (theType), (putDataHere), (obj))
  494.  
  495. #else
  496.  
  497. typedef WEClickLoopProcPtr WEClickLoopUPP;
  498. typedef WEScrollProcPtr WEScrollUPP;
  499. typedef WETSMPreUpdateProcPtr WETSMPreUpdateUPP;
  500. typedef WETSMPostUpdateProcPtr WETSMPostUpdateUPP;
  501. typedef WETranslateDragProcPtr WETranslateDragUPP;
  502. typedef WEDrawTextProcPtr WEDrawTextUPP;
  503. typedef WEPixelToCharProcPtr WEPixelToCharUPP;
  504. typedef WECharToPixelProcPtr WECharToPixelUPP;
  505. typedef WELineBreakProcPtr WELineBreakUPP;
  506. typedef WEWordBreakProcPtr WEWordBreakUPP;
  507. typedef WECharByteProcPtr WECharByteUPP;
  508. typedef WECharTypeProcPtr WECharTypeUPP;
  509. typedef WENewObjectProcPtr WENewObjectUPP;
  510. typedef WEDisposeObjectProcPtr WEDisposeObjectUPP;
  511. typedef WEDrawObjectProcPtr WEDrawObjectUPP;
  512. typedef WEClickObjectProcPtr WEClickObjectUPP;
  513. typedef WEStreamObjectProcPtr WEStreamObjectUPP;
  514.  
  515. #define NewWEClickLoopProc(userRoutine) ((WEClickLoopUPP) (userRoutine))
  516. #define NewWEScrollProc(userRoutine) ((WEScrollUPP) (userRoutine))
  517. #define NewWETSMPreUpdateProc(userRoutine) ((WETSMPreUpdateUPP) (userRoutine))
  518. #define NewWETSMPostUpdateProc(userRoutine) ((WETSMPostUpdateUPP) (userRoutine))
  519. #define NewWETranslateDragProc(userRoutine) ((WETranslateDragUPP) (userRoutine))
  520. #define NewWEDrawTextProc(userRoutine) ((WEDrawTextUPP) (userRoutine))
  521. #define NewWEPixelToCharProc(userRoutine) ((WEPixelToCharUPP) (userRoutine))
  522. #define NewWECharToPixelProc(userRoutine) ((WECharToPixelUPP) (userRoutine))
  523. #define NewWELineBreakProc(userRoutine) ((WELineBreakUPP) (userRoutine))
  524. #define NewWEWordBreakProc(userRoutine) ((WEWordBreakUPP) (userRoutine))
  525. #define NewWECharByteProc(userRoutine) ((WECharByteUPP) (userRoutine))
  526. #define NewWECharTypeProc(userRoutine) ((WECharTypeUPP) (userRoutine))
  527. #define NewWENewObjectProc(userRoutine) ((WENewObjectUPP) (userRoutine))
  528. #define NewWEDisposeObjectProc(userRoutine) ((WEDisposeObjectUPP) (userRoutine))
  529. #define NewWEDrawObjectProc(userRoutine) ((WEDrawObjectUPP) (userRoutine))
  530. #define NewWEClickObjectProc(userRoutine) ((WEClickObjectUPP) (userRoutine))
  531. #define NewWEStreamObjectProc(userRoutine) ((WEStreamObjectUPP) (userRoutine))
  532.  
  533. #define CallWEClickLoopProc(we, userRoutine) \
  534.     (*(userRoutine))((we))
  535. #define CallWEScrollProc(we, userRoutine) \
  536.     (*(userRoutine))((we))
  537. #define CallWETSMPreUpdateProc(we, userRoutine) \
  538.     (*(userRoutine))((we))
  539. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  540.     (*(userRoutine))((we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  541. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  542.     (*(userRoutine))((theDrag), (theItem), (requestedType), (putDataHere))
  543. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  544.     (*(userRoutine))((pText), (textLength), (slop), (styleRunPosition), (we))
  545. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  546.     (*(userRoutine))((pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  547. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  548.     (*(userRoutine))((pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  549. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  550.     (*(userRoutine))((pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  551. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  552.     (*(userRoutine))((pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  553. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  554.     (*(userRoutine))((pText), (textOffset), (script), (we))
  555. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  556.     (*(userRoutine))((pText), (textOffset), (script), (we))
  557. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  558.     (*(userRoutine))((defaultObjectSize), (obj))
  559. #define CallWEDisposeObjectProc(obj, userRoutine) \
  560.     (*(userRoutine))((obj))
  561. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  562.     (*(userRoutine))((destRect), (obj))
  563. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  564.     (*(userRoutine))((hitPt), (modifiers), (clickTime), (obj))
  565. #define CallWEStreamObjectProc(destKind, theType, putDataHere, obj, userRoutine) \
  566.     (*(userRoutine))((destKind), (theType), (putDataHere), (obj))
  567.  
  568. #endif
  569.  
  570.  
  571. /*    WASTE public calls */
  572.  
  573. #ifdef __cplusplus
  574. extern "C" {
  575. #endif
  576.  
  577. /*    creation and destruction */
  578.  
  579. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEReference *we);
  580. pascal void WEDispose(WEReference we);
  581.  
  582. /*    getting variables */
  583.  
  584. pascal Handle WEGetText(WEReference we);
  585. pascal short WEGetChar(long offset, WEReference we);
  586. pascal long WEGetTextLength(WEReference we);
  587. pascal long WECountLines(WEReference we);
  588. pascal long WEGetHeight(long startLine, long endLine, WEReference we);
  589. pascal void WEGetSelection(long *selStart, long *selEnd, WEReference we);
  590. pascal void WEGetDestRect(LongRect *destRect, WEReference we);
  591. pascal void WEGetViewRect(LongRect *viewRect, WEReference we);
  592. pascal Boolean WEIsActive(WEReference we);
  593. pascal long WEOffsetToLine (long offset, WEReference we);
  594.  
  595. /*    setting variables */
  596.  
  597. pascal void WESetSelection(long selStart, long selEnd, WEReference we);
  598. pascal void WESetDestRect(const LongRect *destRect, WEReference we);
  599. pascal void WESetViewRect(const LongRect *viewRect, WEReference we);
  600.  
  601. /*    accessing style run information */
  602.  
  603. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEReference we);
  604. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEReference we);
  605.  
  606. /*    converting byte offsets to screen position and vice versa */
  607.  
  608. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEReference we);
  609. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEReference we);
  610.  
  611. /*    finding words and lines */
  612.  
  613. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEReference we);
  614. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEReference we);
  615.  
  616. /*    making a copy of a text range */
  617.  
  618. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  619.  
  620. /*    getting and setting the alignment style */
  621.  
  622. pascal char WEGetAlignment(WEReference we);
  623. pascal void WESetAlignment(char alignment, WEReference we);
  624.  
  625. /*    recalculating line breaks, drawing and scrolling */
  626.  
  627. pascal OSErr WECalText(WEReference we);
  628. pascal void WEUpdate(RgnHandle updateRgn, WEReference we);
  629. pascal void WEScroll(long hOffset, long vOffset, WEReference we);
  630. pascal void WESelView(WEReference we);
  631.  
  632. /*    handling activate / deactivate events */
  633.  
  634. pascal void WEActivate(WEReference we);
  635. pascal void WEDeactivate(WEReference we);
  636.  
  637. /*     handling key-down events */
  638.  
  639. pascal void WEKey(short key, EventModifiers modifiers, WEReference we);
  640.  
  641. /*    handling mouse-down events and mouse tracking */
  642.  
  643. pascal void WEClick(Point hitPt, EventModifiers modifiers, unsigned long clickTime, WEReference we);
  644.  
  645. /*    adjusting the cursor shape */
  646.  
  647. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEReference we);
  648.  
  649. /*    blinking the caret */
  650.  
  651. pascal void WEIdle(unsigned long *maxSleep, WEReference we);
  652.  
  653. /*    modifying the text and the styles */
  654.  
  655. pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  656. pascal OSErr WEDelete(WEReference we);
  657. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEReference we);
  658. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEReference we);
  659. pascal OSErr WEUseText(Handle hText, WEReference we);
  660.  
  661. /*    undo */
  662.  
  663. pascal OSErr WEUndo(WEReference we);
  664. pascal void WEClearUndo(WEReference we);
  665. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEReference we);
  666. pascal Boolean WEIsTyping(WEReference we);
  667.  
  668. /*    keeping track of changes */
  669.  
  670. pascal unsigned long WEGetModCount(WEReference we);
  671. pascal void WEResetModCount(WEReference we);
  672.  
  673. /*    embedded objects */
  674.  
  675. pascal OSErr WEInstallObjectHandler(FlavorType objectType, WESelector handlerSelector, UniversalProcPtr handler, WEReference we);
  676. pascal OSErr WEInsertObject(FlavorType objectType, Handle objectDataHandle, Point objectSize, WEReference we);
  677. pascal OSErr WEGetSelectedObject(WEObjectReference *obj, WEReference we);
  678. pascal long WEFindNextObject(long offset, WEObjectReference *obj, WEReference we);
  679.  
  680. /*    accessing embedded object attributes */
  681.  
  682. pascal FlavorType WEGetObjectType(WEObjectReference obj);
  683. pascal Handle WEGetObjectDataHandle(WEObjectReference obj);
  684. pascal Point WEGetObjectSize(WEObjectReference obj);
  685. pascal WEReference WEGetObjectOwner(WEObjectReference obj);
  686. pascal long WEGetObjectRefCon(WEObjectReference obj);
  687. pascal void WESetObjectRefCon(WEObjectReference obj, long refCon);
  688.  
  689. /*    clipboard operations */
  690.  
  691. pascal OSErr WECut(WEReference we);
  692. pascal OSErr WECopy(WEReference we);
  693. pascal OSErr WEPaste(WEReference we);
  694. pascal Boolean WECanPaste(WEReference we);
  695.  
  696. /*    Drag Manager support */
  697.  
  698. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEReference we);
  699. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEReference we);
  700. pascal OSErr WEReceiveDrag(DragReference drag, WEReference we);
  701. pascal Boolean WECanAcceptDrag(DragReference drag, WEReference we);
  702. pascal Boolean WEDraggedToTrash(DragReference drag);
  703.  
  704. /*    Script Manager utilities */
  705.  
  706. pascal short WECharByte(long offset, WEReference we);
  707. pascal short WECharType(long offset, WEReference we);
  708.  
  709. /*    Text Services Manager support */
  710.  
  711. pascal OSErr WEInstallTSMHandlers(void);
  712. pascal OSErr WERemoveTSMHandlers(void);
  713. pascal void WEStopInlineSession(WEReference we);
  714.  
  715. /*    additional features */
  716.  
  717. pascal short WEFeatureFlag(short feature, short action, WEReference we);
  718. pascal OSErr WEGetInfo(WESelector selector, void *info, WEReference we);
  719. pascal OSErr WESetInfo(WESelector selector, const void *info, WEReference we);
  720.  
  721. /*    long coordinate utilities */
  722.  
  723. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  724. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  725. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  726. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  727. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  728. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  729. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  730.  
  731. #ifdef __cplusplus
  732. }
  733. #endif
  734.  
  735. #if defined(powerc) || defined (__powerc)
  736. #pragma options align=reset
  737. #endif
  738.  
  739. #endif
  740.